//
//  ZCBVkpJLCFMineHeaderViewfzoLet.m
//  Jlcf_ios
//
//  Created by 邓伟浩 on 2019/4/30.
//  Copyright © 2019 ski. All rights reserved.
//

#import "ZCBVkpJLCFMineHeaderViewfzoLet.h"
#import "rmMqyfJLCFLoginAndRegisterControllerFbzYtj.h"

@interface ZCBVkpJLCFMineHeaderViewfzoLet ()

@property (nonatomic, strong) UIView *vfaCufinfoContentViewBVUtpb;
@property (nonatomic, strong) UIImageView *vhnQcZbackImageViewBXhyPV;

@property (nonatomic, strong) UIView *HMSJIXunLoginedContentViewvEiaoE;
@property (nonatomic, strong) UIView *PZoHMtloginedContentViewVOaxzq;

@property (nonatomic, strong) UILabel *VQOvknamountDesLabelbOJlWj;
@property (nonatomic, strong) UILabel *GAvcnIamountLabelMphKiM; //总资产

@property (nonatomic, strong) UILabel *VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO;
@property (nonatomic, strong) UILabel *hXmEPAintezCFozurestLabelGrseuqnMguKw; // 累计收益

@property (nonatomic, strong) UILabel *ReYiWOinvestDesLabelfUTYRK;
@property (nonatomic, strong) UILabel *KGxPiiinvestLabelQErFcn; // 借出金额

@property (nonatomic, strong) UILabel *WwCEHumoneyDesLabelcmouCq;
@property (nonatomic, strong) UILabel *TvtacpmoneyLabelIfJqAd;

@property (nonatomic, strong) UIButton *WrrxeXchargeBtncgdfYT;
@property (nonatomic, strong) UIButton *bwPsbpgetMoneyBtnhmBiWt;

@property (nonatomic, strong) UIImageView *azURFcuserImageViewgoHzsh;
@property (nonatomic, strong) UILabel *giAZzBstatusLabelmYmPuF;

@end

@implementation ZCBVkpJLCFMineHeaderViewfzoLet

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setUpMineHeaderView];
    }
    return self;
}

- (UIView *)HMSJIXunLoginedContentViewvEiaoE {
    if (!_HMSJIXunLoginedContentViewvEiaoE) {
        _HMSJIXunLoginedContentViewvEiaoE = [[UIView alloc] init];
        
        [_HMSJIXunLoginedContentViewvEiaoE addSubview:({
            _azURFcuserImageViewgoHzsh = [[UIImageView alloc] init];
            _azURFcuserImageViewgoHzsh.image = [UIImage imageNamed:@"icon_mine_user"];
            _azURFcuserImageViewgoHzsh;
        })];
        [_azURFcuserImageViewgoHzsh mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(FitRealValue(98));
            make.centerX.mas_equalTo(_HMSJIXunLoginedContentViewvEiaoE.mas_centerX);
            make.top.mas_equalTo(FitRealValue(200));
        }];
        
        [_HMSJIXunLoginedContentViewvEiaoE addSubview:({
            _giAZzBstatusLabelmYmPuF = [UILabel labelWithText:@"未登录" textColor:QTZ_White font:FONT(12)];
            _giAZzBstatusLabelmYmPuF;
        })];
        [_giAZzBstatusLabelmYmPuF mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(_HMSJIXunLoginedContentViewvEiaoE.mas_centerX);
            make.top.mas_equalTo(_azURFcuserImageViewgoHzsh.mas_bottom).offset(9);
            make.height.mas_equalTo(FitRealValue(32));
        }];
    }
    return _HMSJIXunLoginedContentViewvEiaoE;
}

- (UIView *)PZoHMtloginedContentViewVOaxzq {
    if (!_PZoHMtloginedContentViewVOaxzq) {
        _PZoHMtloginedContentViewVOaxzq = [[UIView alloc] init];
        
        
        [_PZoHMtloginedContentViewVOaxzq addSubview:({
            _VQOvknamountDesLabelbOJlWj = [[UILabel alloc] init];
            _VQOvknamountDesLabelbOJlWj.textColor = [UIColor whiteColor];
            _VQOvknamountDesLabelbOJlWj.font = FONT(10);
            _VQOvknamountDesLabelbOJlWj.text = @"总资产(元)";
            _VQOvknamountDesLabelbOJlWj;
        })];
        
        [_VQOvknamountDesLabelbOJlWj mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_PZoHMtloginedContentViewVOaxzq.mas_left).offset(FitRealValue(40));
            make.height.mas_equalTo(FitRealValue(28));
            make.top.mas_equalTo(_PZoHMtloginedContentViewVOaxzq.mas_top).offset(FitRealValue(180));
        }];
        
        [_PZoHMtloginedContentViewVOaxzq addSubview:({
            _GAvcnIamountLabelMphKiM = [[UILabel alloc] init];
            _GAvcnIamountLabelMphKiM.textColor = [UIColor whiteColor];
            _GAvcnIamountLabelMphKiM.font = FONT(33);
            _GAvcnIamountLabelMphKiM.text = @"0.00";
            _GAvcnIamountLabelMphKiM;
        })];
        [_GAvcnIamountLabelMphKiM mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_VQOvknamountDesLabelbOJlWj.mas_left);
            make.height.mas_equalTo(FitRealValue(66));
            make.top.mas_equalTo(_VQOvknamountDesLabelbOJlWj.mas_bottom).offset(5);
        }];

        [_PZoHMtloginedContentViewVOaxzq addSubview:({
            _VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO = [[UILabel alloc] init];
            _VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO.textColor = [UIColor whiteColor];
            _VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO.font = FONT(10);
            _VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO.text = @"累计收益(元)";
            _VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO;
        })];

        [_VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_PZoHMtloginedContentViewVOaxzq.mas_left).offset(FitRealValue(40));
            make.height.mas_equalTo(FitRealValue(28));
            make.top.mas_equalTo(_GAvcnIamountLabelMphKiM.mas_bottom).offset(FitRealValue(60));
        }];

        [_PZoHMtloginedContentViewVOaxzq addSubview:({
            _hXmEPAintezCFozurestLabelGrseuqnMguKw = [[UILabel alloc] init];
            _hXmEPAintezCFozurestLabelGrseuqnMguKw.textColor = [UIColor whiteColor];
            _hXmEPAintezCFozurestLabelGrseuqnMguKw.font = FONT(20);
            _hXmEPAintezCFozurestLabelGrseuqnMguKw.text = @"0.00";
            _hXmEPAintezCFozurestLabelGrseuqnMguKw;
        })];
        [_hXmEPAintezCFozurestLabelGrseuqnMguKw mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO.mas_left);
            make.height.mas_equalTo(FitRealValue(50));
            make.top.mas_equalTo(_VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO.mas_bottom).offset(5);
        }];

        [_PZoHMtloginedContentViewVOaxzq addSubview:({
            _ReYiWOinvestDesLabelfUTYRK = [[UILabel alloc] init];
            _ReYiWOinvestDesLabelfUTYRK.textColor = [UIColor whiteColor];
            _ReYiWOinvestDesLabelfUTYRK.font = FONT(10);
            _ReYiWOinvestDesLabelfUTYRK.text = @"累计借出金额(本金)";
            _ReYiWOinvestDesLabelfUTYRK;
        })];

        [_ReYiWOinvestDesLabelfUTYRK mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_PZoHMtloginedContentViewVOaxzq.mas_centerX).offset(FitRealValue(40));
            make.height.mas_equalTo(FitRealValue(28));
            make.top.mas_equalTo(_VJUPOSinteOShPwarestDesLabelVPTxiWbGOFBO.mas_top);
        }];

        [_PZoHMtloginedContentViewVOaxzq addSubview:({
            _KGxPiiinvestLabelQErFcn = [[UILabel alloc] init];
            _KGxPiiinvestLabelQErFcn.textColor = [UIColor whiteColor];
            _KGxPiiinvestLabelQErFcn.font = FONT(20);
            _KGxPiiinvestLabelQErFcn.text = @"0.00";
            _KGxPiiinvestLabelQErFcn;
        })];
        [_KGxPiiinvestLabelQErFcn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_ReYiWOinvestDesLabelfUTYRK.mas_left);
            make.height.mas_equalTo(FitRealValue(50));
            make.top.mas_equalTo(_ReYiWOinvestDesLabelfUTYRK.mas_bottom).offset(5);
        }];


    }
    return _PZoHMtloginedContentViewVOaxzq;
}

- (void)setUpMineHeaderView {
    self.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:({
        _vhnQcZbackImageViewBXhyPV = [[UIImageView alloc] init];
        _vhnQcZbackImageViewBXhyPV.image = [UIImage imageNamed:@"icon_mine_topBack"];
        _vhnQcZbackImageViewBXhyPV.contentMode = UIViewContentModeScaleAspectFit;
        _vhnQcZbackImageViewBXhyPV;
    })];
    
    [self addSubview:({
        _vfaCufinfoContentViewBVUtpb = [[UIView alloc] init];
        _vfaCufinfoContentViewBVUtpb;
    })];
    [_vfaCufinfoContentViewBVUtpb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(self);
        make.height.mas_equalTo(FitRealValue(500));
        
    }];
    
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toLogin:)];
    [_vfaCufinfoContentViewBVUtpb addGestureRecognizer:tapGes];
    
    [_vhnQcZbackImageViewBXhyPV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(_vfaCufinfoContentViewBVUtpb);
    }];
    
    
    // 可用余额
    [self addSubview:({
        _WwCEHumoneyDesLabelcmouCq = [[UILabel alloc] init];
        _WwCEHumoneyDesLabelcmouCq.textColor = QTZ_Gray118;
        _WwCEHumoneyDesLabelcmouCq.font = FONT(10);
        _WwCEHumoneyDesLabelcmouCq.text = @"账户余额(元)";
        _WwCEHumoneyDesLabelcmouCq;
    })];
    [_WwCEHumoneyDesLabelcmouCq mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(FitRealValue(40));
        make.height.mas_equalTo(FitRealValue(28));
        make.top.mas_equalTo(_vhnQcZbackImageViewBXhyPV.mas_bottom).offset(FitRealValue(40));
    }];

    [self addSubview:({
        _TvtacpmoneyLabelIfJqAd = [[UILabel alloc] init];
        _TvtacpmoneyLabelIfJqAd.textColor = [UIColor blackColor];
        _TvtacpmoneyLabelIfJqAd.font = FONT(16);
        _TvtacpmoneyLabelIfJqAd.text = @"0.00";
        _TvtacpmoneyLabelIfJqAd;
    })];
    [_TvtacpmoneyLabelIfJqAd mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_WwCEHumoneyDesLabelcmouCq.mas_right).offset(FitRealValue(20));
        make.height.mas_equalTo(FitRealValue(50));
        make.centerY.mas_equalTo(_WwCEHumoneyDesLabelcmouCq.mas_centerY);
    }];

    // 充值
    [self addSubview:({
        _WrrxeXchargeBtncgdfYT = [UIButton buttonWithType:UIButtonTypeCustom];
        NSString *chargeTitle = @"充值";
        NSAttributedString *chargeAttributeStr = [[NSAttributedString alloc] initWithString:chargeTitle attributes:@{NSFontAttributeName:FONT(10), NSForegroundColorAttributeName:[UIColor whiteColor]}];
        [_WrrxeXchargeBtncgdfYT setAttributedTitle:chargeAttributeStr forState:UIControlStateNormal];
        _WrrxeXchargeBtncgdfYT.layer.cornerRadius = FitRealValue(50)/2;
        _WrrxeXchargeBtncgdfYT.backgroundColor = Theme_Color;
        _WrrxeXchargeBtncgdfYT;
    })];
    [_WrrxeXchargeBtncgdfYT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.mas_right).offset(-FitRealValue(30));
        make.height.mas_equalTo(FitRealValue(50));
        make.width.mas_equalTo(FitRealValue(110));
        make.centerY.mas_equalTo(_WwCEHumoneyDesLabelcmouCq.mas_centerY);
    }];

    // 提现
    [self addSubview:({
        _bwPsbpgetMoneyBtnhmBiWt = [UIButton buttonWithType:UIButtonTypeCustom];
        NSString *getTitle = @"提现";
        NSAttributedString *getAttributeStr = [[NSAttributedString alloc] initWithString:getTitle attributes:@{NSFontAttributeName:FONT(10), NSForegroundColorAttributeName:Theme_Color}];
        [_bwPsbpgetMoneyBtnhmBiWt setAttributedTitle:getAttributeStr forState:UIControlStateNormal];
        _bwPsbpgetMoneyBtnhmBiWt.layer.cornerRadius = FitRealValue(50)/2;
        _bwPsbpgetMoneyBtnhmBiWt.layer.borderColor = Theme_Color.CGColor;
        _bwPsbpgetMoneyBtnhmBiWt.layer.borderWidth = 1;
        _bwPsbpgetMoneyBtnhmBiWt;
    })];
    [_bwPsbpgetMoneyBtnhmBiWt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_WrrxeXchargeBtncgdfYT.mas_left).offset(-FitRealValue(30));
        make.height.mas_equalTo(FitRealValue(50));
        make.width.mas_equalTo(FitRealValue(110));
        make.centerY.mas_equalTo(_WrrxeXchargeBtncgdfYT.mas_centerY);
    }];


    [_WrrxeXchargeBtncgdfYT addTarget:self action:@selector(toCharge:) forControlEvents:UIControlEventTouchUpInside];
    [_bwPsbpgetMoneyBtnhmBiWt addTarget:self action:@selector(toGetMoney:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)reloadHeaderInfoBy:(PBseiKJLCFMineDataModelWqnMcO *)mineDataModel {
    [self.vfaCufinfoContentViewBVUtpb removeAllSubviews];
    
    if (mineDataModel) {

        [self.vfaCufinfoContentViewBVUtpb addSubview:self.PZoHMtloginedContentViewVOaxzq];
        [self.PZoHMtloginedContentViewVOaxzq mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(self.vfaCufinfoContentViewBVUtpb);
        }];
        _GAvcnIamountLabelMphKiM.text = mineDataModel.accountTotal;
        _hXmEPAintezCFozurestLabelGrseuqnMguKw.text = mineDataModel.interestTotal;
        _KGxPiiinvestLabelQErFcn.text = mineDataModel.investTotal;
        
        _TvtacpmoneyLabelIfJqAd.text = mineDataModel.userMoney;
        
    } else {
        [self.vfaCufinfoContentViewBVUtpb addSubview:self.HMSJIXunLoginedContentViewvEiaoE];
        [self.HMSJIXunLoginedContentViewvEiaoE mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(self.vfaCufinfoContentViewBVUtpb);
        }];
        _TvtacpmoneyLabelIfJqAd.text = @"0.00";
    }
}

- (void)toLogin:(UITapGestureRecognizer *)tap {
    if (![[JLCFRegisterService shareService] hasToken]) {
        [[[JinLiCaiFuApplicationEntrace shareEntrance] currentNavController] pushViewController:[rmMqyfJLCFLoginAndRegisterControllerFbzYtj new] animated:YES];
    }
    
}

- (void)toCharge:(UIButton *)button {
    if (self.chargeCliced) {
        self.chargeCliced();
    }
}

- (void)toGetMoney:(UIButton *)button {
    if (self.getMoneyClicked) {
        self.getMoneyClicked();
    }
}

@end
